Skip to content

通过共享内存连接远程服务端 - ConnectRemoteShm

函数简介

A 端 通过本机共享内存B 端 启动共享内存远程调度服务 - StartRemoteServerShm 建立远程调用连接(同机进程间通讯)。并在连接后自动完成 B 端 Reg

接口名称

ConnectRemoteShm

DLL调用

c
int32_t ConnectRemoteShm(int64_t instance, int32_t serverPid,
                         char* token, int32_t timeoutMs);

参数说明

参数名类型说明
instance长整数型OLAPlug 对象指针,由 CreateCOLAPlugInterFace 接口生成。
serverPid整数型B 端进程 PID;0 表示自动查找名为 RemoteServer.exe 的进程(可在SetConfig中配置)。
token字符串鉴权令牌,须与 B 端 StartRemoteServerShm 一致。
timeoutMs整数型超时(毫秒);0 可使用默认。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int ret = ola.ConnectRemoteShm(0, "StartRemoteServerShm", 0);
csharp
using OLAPlug;

var ola = new OLAPlugServer();
int ret = ola.ConnectRemoteShm(0, "StartRemoteServerShm", 0);
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
ret = ola.ConnectRemoteShm(0, "StartRemoteServerShm", 0)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
int ret = ola.ConnectRemoteShm(0, "StartRemoteServerShm", 0);
cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.ConnectRemoteShm(0, "StartRemoteServerShm", 0)
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.ConnectRemoteShm(0, "StartRemoteServerShm", 0)
text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.ConnectRemoteShm(0, “StartRemoteServerShm”, 0)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.ConnectRemoteShm(0, "StartRemoteServerShm", 0);
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.ConnectRemoteShm(0, "StartRemoteServerShm", 0)
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int32_t ret = ola.ConnectRemoteShm(0, "StartRemoteServerShm", 0);

原生 DLL 调用

cpp
ConnectRemoteShm(instance, 0, "StartRemoteServerShm", 0);
csharp
using System.Runtime.InteropServices;
using System.Text;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int ConnectRemoteShm(long ola, int serverPid, string token, int timeoutMs);

ConnectRemoteShm(instance, 0, "StartRemoteServerShm", 0);
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
ola.ConnectRemoteShm(instance, 0, "StartRemoteServerShm", 0)

返回值

1 成功,0 失败。

注意事项

  • 仅 A 端使用;B 端须先启动共享内存服务。